<?php
declare (strict_types=1);

namespace app\admin\validates;

use think\Validate;

/**
 * Role验证器
 */
class RoleValidate extends Validate
{
    /**
     * 验证规则
     * @var array
     */
    protected $rule = [
        'id' => 'require|number',
        'role_name' => 'chsDash|max:50',
        'role_key' => 'chsDash|max:50',
        'orderby' => 'require|number',
        'status' => 'require|number',
        'menu_ids' => 'array',
        'remark' => 'max:255',
    ];

    /**
     * 验证字段描述
     * @var string[]
     */
    protected $field = [
        'id' => 'ID',
        'role_name' => '角色名称',
        'role_key' => '角色权限字符串',
        'orderby' => '角色排序',
        'status' => '角色状态',
        'menu_ids' => '角色拥有的菜单ID',
        'remark' => '备注',
    ];

    /**
     * 验证场景
     * @var array
     */
    protected $scene = [
        'add' => ['role_name', 'role_key', 'orderby', 'status', 'menu_ids', 'remark'],
        'edit' => ['id', 'role_name', 'role_key', 'orderby', 'status', 'menu_ids', 'remark'],
    ];

}